package jin.si.controller;

import jin.si.pojo.JsActicleCategray;
import jin.si.pojo.JsMicrocircle;
import jin.si.service.JsActicleCategroyService;
import jin.si.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:JsActicleCategroyController
 * Package:jin.si.controller
 * Description:
 *
 * @Date:2022/3/22 下午 3:26
 * @Author: WYH
 */
@RestController
@RequestMapping("/microPage")
public class JsActicleCategroyController {

    @Autowired
    private JsActicleCategroyService jsActicleCategroyService;

    /**
     * @Author WYH
     * @Description //TODO 查询微圈分类
     * @Date 下午 3:32 2022/3/22
     * @Param
     * @return  JsonData
     **/
    @RequestMapping("/getJsMicrocircle")
    public JsonData getJsMicrocircle(){
        List<JsActicleCategray> jsMicrocircle = jsActicleCategroyService.getJsMicrocircle();
        return jsMicrocircle != null ? JsonData.buildSuccess(jsMicrocircle) : JsonData.buildError("数据格式异常");
    }

    /**
     * @Author WYH
     * @Description //TODO 查看微圈分类对应的课程
     * @Date 上午 13:51 2022/3/28
     * @Param acticleCategoryId
     * @return   List<JsMicrocircle>
     **/
    @RequestMapping("/getJsMicrocircleById")
    public JsonData getJsMicrocircleById(String acticleCategoryId) {
        System.err.println(acticleCategoryId);
        List<JsMicrocircle> jsMicrocircleById = jsActicleCategroyService.getJsMicrocircleById(acticleCategoryId);
        return jsMicrocircleById != null ? JsonData.buildSuccess(jsMicrocircleById) : JsonData.buildError("数据格式异常");
    }

    /**
     * @Author WYH
     * @Description //TODO 根据微圈id查询数据
     * @Date 下午 2:55 2022/3/29
     * @Param microcircleId
     * @return  JsMicrocircle
     **/
    @RequestMapping("/selectJsMicrocircleById")
    public JsonData selectJsMicrocircleById(String microcircleId){
        System.err.println(microcircleId);
        JsMicrocircle jsMicrocircle = jsActicleCategroyService.selectJsMicrocircleById(microcircleId);
        return jsMicrocircle != null ? JsonData.buildSuccess(jsMicrocircle) : JsonData.buildError("数据格式异常");
    }
}
